// #ifndef VUE3
import Vue from 'vue'
import App from './App'
import navBar from './components/navBar'
import requestLoading from './components/uni-loading/uni-loading.vue'
import * as filters from './filters/index.js'
import {
	http
} from '@/utils/request';
// 引入全局存储
import store from '@/store';
import mHelper from '@/utils/helper';

//过滤器
Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key])
})
Vue.component('an-nav-bar', navBar);
Vue.component('uni-loading', requestLoading);
function showLoading() {
	store.commit('request_show_loading');
}

function hideLoading() {
	store.commit('request_hide_loading');
}
Vue.prototype.$showLoading = showLoading; //全局显示动画可以 this.$showLoading();
Vue.prototype.$hideLoading = hideLoading; //全局隐藏动画可以 this.$hideLoading();
// 网络状态监听
uni.getNetworkType({
	success: res => {
		store.dispatch('networkStateChange', res.networkType);
	}
});
uni.onNetworkStatusChange(function(res) {
	store.dispatch('networkStateChange', res.networkType);
});
// 挂载全局自定义方法
Vue.prototype.$mStore = store;
Vue.prototype.$mHelper = mHelper;
Vue.prototype.$http = http;
Vue.config.productionTip = false

import Common from './utils/common.js'
Vue.prototype.$common = Common

App.mpType = 'app'
const app = new Vue({
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
import App from './App.vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif
